<?php

/* Copyright 2010 John Hooley

	  
    This file is part of Portfolio Zen.


    Portfolio Zen is free software: you can redistribute it and/or modify

    it under the terms of the GNU General Public License as published by

    the Free Software Foundation, either version 3 of the License, or

    (at your option) any later version.



    Portfolio Zen is distributed in the hope that it will be useful,

    but WITHOUT ANY WARRANTY; without even the implied warranty of

    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

    GNU General Public License for more details.



    You should have received a copy of the GNU General Public License

    along with Portfolio Zen.  If not, see <http://www.gnu.org/licenses/>.

 */ 

defined('_JEXEC') or die('Restricted access');

class GalleriesLayoutHelperKite implements GalleriesLayoutHelper {

  private $_view = false;
  private $_resources = array();

  public function __construct(&$view){
    $this->_view =& $view;
  }

  public function build(){
    $this->_addResources($this->_view->params->get('position'));
    $this->_loadLayoutColors();
  }

  protected function _addResources(){
    if($this->_view->params->get('internalDojo') === "1") {
      $this->_queResource('Script', $this->_view->base . 'assets/js/dojo/dojo.js');
    } else {
      $this->_queResource('Script', 'http://o.aolcdn.com/dojo/1.5/dojo/dojo.xd.js');
    }
    $this->_queResource('Script', $this->_view->base . 'assets/js/slideControls.js');
    $this->_queResource('StyleSheet', $this->_view->base ."assets/css/base.css");
    $this->_queResource('StyleSheet', $this->_view->base ."assets/css/kite.css");
  }

  protected function _loadLayoutColors(){
    $colors = array('categoryBack' => $this->_getFilteredColor('categoryback', '#979300'),
		    'categoryActive' => $this->_getFilteredColor('categoryactive', '#000000'),
		    'slideBack' => $this->_getFilteredColor('slideback', '#828282'),
		    'slideActive' => $this->_getFilteredColor('slideactive', '#979300'));
    foreach($colors as $key => &$value){
      $this->_view->assignRef($key, $value);
    }
  }

  protected function _getFilteredColor($key, $default){
    return new ZenColor($this->_view->params->get($key, $default), $default);
  }

  private function _queResource($type, $resource){
    $this->_resources[] = array($type => $resource);
  }

  public function getResources(){
    return $this->_resources;
  }


}